package com.grape.advice;

import com.grape.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author fuhehuang
 * @email 2628279194@qq.com
 */
@RestControllerAdvice
@Slf4j
public class ControllerAdvice extends CommonControllerAdvice {

    @ExceptionHandler(value = UsernameNotFoundException.class)
    public R handler(UsernameNotFoundException ex){
        ex.printStackTrace();
        log.error("认证出现错误：{}", ex.getMessage());
        return R.operationError(ex.getMessage(), ex.getMessage(), ex.getMessage());
    }

}
